package com.czh.springboot04.service.serviceimpl;

import com.czh.springboot04.entity.CourseReply;
import com.czh.springboot04.mapper.CourseReplyMapper;
import com.czh.springboot04.service.CourseReplyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseReplyServiceImpl implements CourseReplyService {
    @Autowired
    CourseReplyMapper courseReplyMapper;

    public int insertCourseReply(CourseReply courseReply) {
        return courseReplyMapper.insertCourseReply(courseReply);
    }

    @Override
    public int updateCourseReplyById(CourseReply courseReply) {
        return courseReplyMapper.updateCourseReplyById(courseReply);
    }

    @Override
    public CourseReply selectCourseReplyById(Integer id) {
        return courseReplyMapper.selectCourseReplyById(id);
    }

    @Override
    public int deleteCourseReplyById(Integer id) {
        return courseReplyMapper.deleteCourseReplyById(id);
    }

    @Override
    public int deleteCourseReplyByList(List<Integer> idList) {
        return courseReplyMapper.deleteCourseReplyByList(idList);
    }

    @Override
    public PageInfo<CourseReply> selectCourseReplyAll(String nickName, String title, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<CourseReply> list = courseReplyMapper.selectCourseReplyAll(nickName, title);
        PageInfo<CourseReply> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
